<!--
 * @Author: ZCL
 * @Date: 2020-05-21 13:49:25
 * @LastEditors: ZCL
 * @LastEditTime: 2020-05-21 13:49:25
-->
<template>
  <!-- 上报遗失 -->
  <div class="reportedLost">
    <van-field
      v-model="check_remark"
      type="textarea"
      placeholder="请输入遗失原因(内容不少于10个字)"
      rows="5"
      autosize
      label="遗失原因"
      colon
      maxlength="50"
      show-word-limit
      required
    />
    <van-button type="info" block class="mt-42" @click="submitLoss">提交</van-button>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  name: 'ReportedLost',
  data () {
    return {
      check_remark: '' // 遗失原因
    };
  },
  computed: {
    ...mapGetters(['dept_id'])
  },
  methods: {
    // 提交报失
    submitLoss () {
      if (!this.check_remark) {
        this.$toast('请填写遗失原因');
        return;
      }
      if (this.check_remark && this.check_remark.length < 10) {
        this.$toast('遗失原因不少于10个字');
        return;
      }
      let params = {
        id: this.$route.query.id,
        check_res: 4,
        check_remark: this.check_remark,
        check_url: ''
      };
      this.$api.postAssetCheckCheckResult(params).then(res => {
        if (res.code === 0) {
          this.$toast.success('报失成功');
          this.$router.replace({
            name: 'inventory-detail',
            query: {
              dept_ids: this.dept_id,
              id: this.$route.query.task_id
            }
          });
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.reportedLost {
  padding: 15px;
  ::v-deep {
    .van-field__label {
      width: 70px;
    }
  }
}
</style>
